﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using Sharp.Portal;
using Sharp.Portal.Interface;
using Sharp.Portal.Mvc.List;
using Sharp.Portal.Other;

namespace Sharp.WebBooter.Areas.Platform.Models
{
    /// <summary>
    /// 角色
    /// </summary>
    [Title("角色管理"), ModuleItem(typeof(RoleViewModel))]
    [DataHandler(ModuleOP.Create, "新增", 1)]
    [DataHandler(ModuleOP.Edit, "修改", 2)]
    [DataHandler(ModuleOP.Delete, "删除", 3)]
    [DataHandler("Permission", "功能权限", 4, OnClientClick = "new Role().ShowWindow();", Icon = "fa fa-paragraph")]
    [DataHandler("OrgData", "数据权限", 5, OnClientClick = "new Role().OrgDataWindow();", Icon = "fa fa-superpowers")]
    public class RoleIndexViewModel : Sharp.Portal.AdminLTE.BSSharpList
    {
        public RoleIndexViewModel()
        {
            this.Feature = ListFeature.MultiSelect | ListFeature.Paging | ListFeature.RowNumber;
            this.IsUseOrgTreeLayout = true;
            this.ImportJavascript = "~/Areas/Platform/Scripts/Role.js";
        }

        /// <summary>
        /// 自定义查询面板
        /// </summary>
        protected override void InitQueryPanel()
        {
            base.InitQueryPanel();
            this.QueryItems.Add(new QueryItem()
            {
                Name = "OrgId",
                SearchFor = "OrgId",
                IsHiddenField = true,
                ValueFrom = QueryItem.ValueFromType.DefaultValue
            });
        }

        [HiddenInput]
        public int Id { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        [Column(Text = "名称", Width = 150, Order = 0), QueryOption(Option = QueryFeature.DefualtQuery)]
        public string Name { get; set; }

        [Column(Text = "所属", Width = 150, Order = 1, DataIndex = "org.title")]
        public string OrgTitle { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        [Column(Text = "备注", Order = 2)]
        public string Remark { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        [DateColumn(Text = "更新时间", Width = 160, Order = 1, Format = "YYYY-MM-DD hh:mm:ss")]
        public System.DateTime? ModifiTime { get; set; }

    }
}

